import { createRouter, createWebHistory } from 'vue-router'
// import { userUserStore } from '@/stores'

const routes = [
    {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/HomePage/index.vue')
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/Login/index2.vue')
    },
    {
        path: '/',
        redirect: '/home' // 将根路径重定向至 Home 页面
    },
    {
        path: '/layout',
        name: 'Layout',
        component: () => import('@/views/Layout/LayoutTest.vue'),
        // redirect: '/subject/manage',
        // redirect: '/subject/manage',
        // redirect: 'Subject',
        children: [
            {
                // 根路径重定向的地方=>科目管理（不能删除）
                path: '/layout',
                name: 'Subject',
                component: () => import('@/views/subjectManagement/index.vue'),
            },
            {
                path: '/manage',
                // name:'TargetManage',
                // component: () => import('@/views/examineTarget/index.vue'),
                component: () => import('@/views/childrenApp/index.vue'),
                redirect: 'Syllabus',
                children: [
                    {
                        path: '/manage/:subId',
                        name: 'TargetManage',
                        component: () => import('@/views/examineTarget/index.vue'),
                    },
                    {
                        path: 'questionTypes/:subId',
                        name: 'QuestionTypes',
                        component: () => import('@/views/paperItemInfoInput/index.vue')
                    },
                    {
                        path: 'title/:subId',
                        name: 'Title',
                        component: () => import('@/views/itemBank/index.vue')
                    },
                    {
                        name: "paperList",
                        path: 'paper/list/:subId',
                        component: () => import('@/views/paperList/index.vue'),
                    },
                    // {
                    //   path: '/questionTypes/target/:subId',
                    //   component: () => import('@/views/paperItemInfoInput/index.vue')
                    // },
                    {
                        name: "paperManage",
                        path: 'paperManage/:subId',
                        component: () => import('@/views/paperManage/index.vue')
                    },
                    {
                        name: "Syllabus",
                        path: 'syllabus/:subId',
                        component: () => import('@/views/CourseManagement/instructionalProgramme/index.vue')
                    },
                    {
                        name: "paperAnalysis",
                        path: 'paperAnalysis/:subId',
                        component: () => import('@/views/paperAnalysis/index.vue')
                    },
                    {
                        name: "objectAnalysis",
                        path: 'objectAnalysis/:subId',
                        component: () => import('@/views/objectAnalysis/index.vue')
                    },
                ]
            },
            {
                path: 'personal',
                name: 'Personal',
                component: () => import('@/views/personalCenter/index.vue'),
            }
            // children:[

            //     {
            //       path: '/manage/:subId',
            //       name:'TargetManage',
            //       component: () => import('@/views/examineTarget/index.vue'),
            // },
            //     {
            //       path: '/manage/title/:subId',
            //       // name: "TitleManage",
            //       component: () => import('@/views/itemBank/index.vue')
            //     },
            //     {
            //       path:'/manage/questionTypes/:subId',
            //       component: () => import('@/views/paperItemInfoInput/index.vue')
            //     },
            //     {
            //       // name:"paperList",
            //       path: '/manage/paper/:subId',
            //       component: () => import('@/views/paperList/index.vue'),
            //     },

            //     {
            //       // name: "paperManage",
            //       path: '/manage/paperManage/:subId',
            //       component: () => import('@/views/paperManage/index.vue')
            //     }
            // {
            //   path: '/examine/target/:subId',
            //   name:'TargetManage',
            //   component: () => import('@/views/examineTarget/index.vue'),
            //   children:[
            // {
            //   path: '/title/manage/:subId',
            //   name: "TitleManage",
            //   component: () => import('@/views/itemBank/index.vue')
            // },
            // {
            //   // name:"paperList",
            //   path: '/paper/list/:subId',
            //   component: () => import('@/views/paperList/index.vue'),
            // },
            // {
            //   path:'/questionTypes/target/:subId',
            //   component: () => import('@/views/paperItemInfoInput/index.vue')
            // },
            // {
            //   // name: "paperManage",
            //   path: '/paperManage/:subId',
            //   component: () => import('@/views/paperManage/index.vue')
            // }
        ]
    },
    // {
    //   path: '/examine/target/:subId',
    //   name:'TargetManage',
    //   component: () => import('@/views/examineTarget/index.vue'),
    // },
    // {
    //   path: '/title/manage/:subId',
    //   name: "TitleManage",
    //   component: () => import('@/views/itemBank/index.vue')
    // },
    // {
    //   name:"paperList",
    //   path: '/paper/list/:subId',
    //   component: () => import('@/views/paperList/index.vue'),
    // },
    // {
    //   path:'/questionTypes/target/:subId',
    //   component: () => import('@/views/paperItemInfoInput/index.vue')
    // },
    // {
    //   name: "paperManage",
    //   path: '/paperManage/:subId',
    //   component: () => import('@/views/paperManage/index.vue')
    // }
]
//   }
// ]
// 创建 router 实例
const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes
})


// router.beforeEach((to, from, next) => {
//   const storedToken = localStorage.getItem('token')
//   // console.log('outside');
//   if (!storedToken && to.path !== '/login') {
//     // console.log('INside');
//     next('/login')
//     // return '/login'
//   }

//   next()
// })

export default router


